Telegram Group & Telegram Channel
🧩 Сложная задача по Python для опытных разработчиков

Что выведет следующий код?


def func(a, L=[]):
L.append(a)
return L

print(func(1))
print(func(2))
print(func(3))


Варианты ответа:
A)

[2]
[3]

B)

[1, 2]
[1, 2, 3]

C)

[1]
[1]

D)

[2]
[3]


---

Правильный ответ: B

Почему:
Списки по умолчанию (
L=[]) в Python инициализируются один раз при определении функции, а не каждый раз при вызове. Поэтому изменения сохраняются между вызовами func. Это классическая "ловушка" со значениями по умолчанию!

@python_job_interview



tg-me.com/python_job_interview/1068
Create:
Last Update:

🧩 Сложная задача по Python для опытных разработчиков

Что выведет следующий код?


def func(a, L=[]):
L.append(a)
return L

print(func(1))
print(func(2))
print(func(3))


Варианты ответа:
A)

[2]
[3]

B)

[1, 2]
[1, 2, 3]

C)

[1]
[1]

D)

[2]
[3]


---

Правильный ответ: B

Почему:
Списки по умолчанию (
L=[]) в Python инициализируются один раз при определении функции, а не каждый раз при вызове. Поэтому изменения сохраняются между вызовами func. Это классическая "ловушка" со значениями по умолчанию!

@python_job_interview

BY Python вопросы с собеседований


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/python_job_interview/1068

View MORE
Open in Telegram


Python вопросы с собеседований Telegram | DID YOU KNOW?

Date: |

Telegram Be The Next Best SPAC

I have no inside knowledge of a potential stock listing of the popular anti-Whatsapp messaging app, Telegram. But I know this much, judging by most people I talk to, especially crypto investors, if Telegram ever went public, people would gobble it up. I know I would. I’m waiting for it. So is Sergei Sergienko, who claims he owns $800,000 of Telegram’s pre-initial coin offering (ICO) tokens. “If Telegram does a SPAC IPO, there would be demand for this issue. It would probably outstrip the interest we saw during the ICO. Why? Because as of right now Telegram looks like a liberal application that can accept anyone - right after WhatsApp and others have turn on the censorship,” he says.

What is Secret Chats of Telegram

Secret Chats are one of the service’s additional security features; it allows messages to be sent with client-to-client encryption. This setup means that, unlike regular messages, these secret messages can only be accessed from the device’s that initiated and accepted the chat. Additionally, Telegram notes that secret chats leave no trace on the company’s services and offer a self-destruct timer.

Python вопросы с собеседований from no


Telegram Python вопросы с собеседований
FROM USA